<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<link rel="stylesheet" type="text/css" href="/public/hui/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/public/hui/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/public/hui/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/public/hui/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/public/hui/static/h-ui.admin/css/style.css" />
<title>CI 后台系统 管理员添加</title>
</head>
<body>
<article class="cl pd-20  col-xs-10 col-xs-offset-1">
	<form action="" method="post" class="form form-horizontal" id="form">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">* </span>所属模块：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                <select class="select" size="1" name="module_id" id="module_id">
                    <option value="">请选择</option>
                    <? foreach ($list as $k=>$v):?>
                        <option value="<?=$k?>"><?=$v['name']?></option>
                    <? endforeach;?>
                </select>
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">* </span>所属分类：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                <select class="select" size="1" name="classify_id" id="classify_id">
                    <option value="">请选择</option>
                </select>
                </span>
            </div>
        </div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">* </span>权限名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder="" id="name" name="name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">* </span>权限代码：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text"  value="" placeholder="方法名" id="code" name="code">
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>


<script type="text/javascript" src="/public/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="/public/lib/layer/layer.js"></script>
<script type="text/javascript" src="/public/hui/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="/public/hui/static/h-ui.admin/js/H-ui.admin.page.js"></script>
<script type="text/javascript" src="/public/lib/validate/jquery.validate.min.js"></script>
<script type="text/javascript" src="/public/admin.js"></script>
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form").validate({
		rules:{
            module_id:{
				required:true
			},
            classify_id:{
                required:true
            },
            name:{
				required:true
			},
            code:{
				required:true
			}
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
            $.ajax({
                dataType:'json',
                type: 'post',
                url: '/Systems/authority_do',
                data: $('#form').serialize(),
                success: function(data){
                    if(1 == data){
                        layer.msg('增加成功!', {
                            icon: 1,
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        }, function(){
                            parent.layer.closeAll();
                        });
                    }else{
                        layer.msg('增加失败!');
                    }
                }
            });
		}
	});

    var s = json_arr('<?=$li;?>');
    $("#module_id").change(function(){
        var val = $(this).children('option:selected').val();
        if(!val){
            $('.o').remove();
            return ;
        }
        var c = s[val]['arr'];
        var o = '';
        $.each(c,function(){
            o += '<option value="'+this.id+'" class="o">'+this.name+'</option>';
        });
        $("#classify_id").append(o);
    });
});
</script>
</body>
</html>